package com.nthink.indicators.controller;


import com.nthink.indicators.pojo.hospitalindicators.HumanResources;
import com.nthink.indicators.pojo.hospitalindicators.ResourceAllocation;
import com.nthink.indicators.service.hospitalindicators.HumanResourcesService;
import com.nthink.indicators.service.hospitalindicators.ResourceAllocationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class HelloController {

    @Autowired
    private ResourceAllocationService resourceAllocationService;
    @Autowired
    private HumanResourcesService humanResourcesService;

    @RequestMapping("/")
    public String helloWorld() {
        return "index";
    }

    @GetMapping("/hospitalIncome")
    public String hospitalIncome() {
        return "hospital/hospital_income";
    }

    @GetMapping("/resourceAllocation")
    public String resourceAllocation(Model model) {
        ResourceAllocation resourceAllocation = resourceAllocationService.getData();
        model.addAttribute("dataModel", resourceAllocation);
        return "hospital/resource_allocation";
    }

    @GetMapping("/humanResources")
    public String humanResources(Model model) {
        HumanResources humanResources = humanResourcesService.getData();
        int openBedCount = resourceAllocationService.getBedCount();
        humanResources.setPharmaceuticalProfessionalsPer100Beds((humanResources.getPharmaceuticalProfessionals() / ((double) openBedCount / 100)));
        model.addAttribute("dataModel", humanResources);
        return "hospital/human_resources";
    }

    @GetMapping("/workload")
    public String workload() {
        return "indicators/workload";
    }

    @GetMapping("/workloadYear")
    public String workloadYear() {
        return "indicators/workload_year";
    }

    @GetMapping("/assets")
    public String assets() {
        return "indicators/assets";
    }

    @GetMapping("/dip")
    public String dip() {
        return "indicators/dip";
    }

    @GetMapping("/baseIndex")
    public String baseIndex() {
        return "qualitymanagement/base_index";
    }

    @GetMapping("/safeManagement")
    public String safeManagement() {
        return "qualitymanagement/safe_management";
    }

    @GetMapping("/clinicalPathway")
    public String clinicalPathway() {
        return "qualitymanagement/clinical_pathway";
    }

    @GetMapping("/drugManagement")
    public String drugManagement() {
        return "qualitymanagement/drug_management";
    }
}
